<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let str = "<div>我的{{name}}</div>";
      let pattern = /{{([a-zA-Z]+)}}/;
      let res = pattern.exec(str);
      console.log(res); // res[0]是{{name}}  res[1]是name
      str = str.replace(res[0], res[1]);
      console.log(str); // "<div>我的name</div>
    </script>
  </body>
</html>
